package com.chang.multithread.MultiLock;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

@Slf4j
public class BigHome {
    private  final Object studyHome=new Object();
    private  final Object sleepHome=new Object();
    public void sleep(){
        //synchronized (this){
        synchronized (sleepHome){
            log.debug("睡觉1小时");
            try {
                TimeUnit.SECONDS.sleep(1);
              } catch (InterruptedException e) {
              e.printStackTrace(); }
        }
    }
    public void study(){
        //synchronized (this){
        synchronized (studyHome){
            log.debug("学习2小时");
            try {
                TimeUnit.SECONDS.sleep(2);
              } catch (InterruptedException e) {
              e.printStackTrace(); }
        }
    }
}
class test{
    public static void main(String[] args) {
        BigHome bigHome=new BigHome();
        new Thread(()->{
         bigHome.study();
        },"someone").start();
        new Thread(()->{
            bigHome.sleep();
        },"otherone").start();
    }
}
